home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / AIAT / Headers / Corpus / HFSIterator.h < prev    next >
Encoding:
Text File  |  1998-04-16  |  2.1 KB  |  87 lines  |  [TEXT/CWIE]

  1. // HFSIterator.h
  2. //    Copyright:    © 1994 - 1998 by Apple Computer, Inc., all rights reserved.
  3.  
  4. // a tool for efficiently implementing IADocIterator on HFS file systems
  5.  
  6. #pragma once
  7. #ifndef HFSIterator_h
  8. #define HFSIterator_h
  9.  
  10. #pragma import on
  11.  
  12. #if PRAGMA_STRUCT_ALIGN
  13.     #pragma options align=power
  14. #endif
  15.  
  16. #include "IACommon.h"
  17.  
  18. #include <Files.h>
  19. #include <Time.h>
  20.  
  21. #pragma IA_BEGIN_EXPORTS
  22.  
  23. struct DirectoryInfo {
  24.     long        id;                                // the id
  25.     short        length;                            // the number of files
  26. private:
  27.     void*        operator new(size_t size);        // stack or array allocate only
  28. };
  29.  
  30. //  progress report support
  31. //typedef void TProgressFn(float percent, void* data);
  32.  
  33. class HFSIterator : public IAObject {
  34. public:
  35.                         HFSIterator(short vRefNum, long rootDirId = 2, 
  36.                         TProgressFn*    progressFn = NULL,
  37.                         clock_t            progressFreq = 0xFFFFFFFFul, // never
  38.                         void*            appData = NULL);
  39.                                         
  40.                         ~HFSIterator();
  41.     bool                Increment();
  42.  
  43.     CInfoPBRec*         GetPBRec() const {return pb;}
  44.     
  45.     // Accessors needed to override Increment()
  46.     DirectoryInfo*        GetDirInfos() const {return dirInfos;}
  47.     long                GetDirCount() const {return dirCount;}
  48.     
  49.     uint32                GetDir() const {return dir;}
  50.     void                SetDir(uint32 newValue) {dir = newValue;}
  51.     
  52.     short                GetDirIndex() const {return dirIndex;}
  53.     void                SetDirIndex(short newValue) {dirIndex = newValue;}
  54.  
  55.     TProgressFn*    GetProgressFn() const     {return fProgressFn;}
  56.     void*            GetProgressData() const     {return fProgressData;}
  57.     clock_t            GetProgressFreq() const     {return fProgressFreq;}
  58.     
  59. protected:
  60.     
  61.     void                CollectDirInfo();
  62.  
  63. private:
  64.     void                CollectDirInfoInternal(uint32* dirInfosLen);
  65.     
  66.     TProgressFn*        fProgressFn;
  67.     void*                fProgressData;
  68.     clock_t                fProgressFreq;
  69.  
  70.     CInfoPBRec*            pb;                    // info about current file
  71.     DirectoryInfo*        dirInfos;            // sorted array of directory ids for current volume
  72.     long                dirCount;            // length of dirInfos
  73.     uint32                dir;                // index in dirInfos of directory being processed
  74.     short                dirIndex;            // index into directory being processed
  75.  
  76. };
  77.  
  78. #pragma IA_END_EXPORTS
  79.  
  80. #if PRAGMA_STRUCT_ALIGN
  81.     #pragma options align=reset
  82. #endif
  83.  
  84. #pragma import reset
  85.  
  86. #endif
  87.